<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Gosub : Return</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<font face="Verdana, sans-serif" size="2"><p align="center"><b><font size="5">Gosub : Return</font></b></p>

<br><b>语法</b><blockquote><pre><font face="Courier New, Courier, mono"size="2"><b><font color="#3A3966">Gosub</font></b> MyLabel 
   
MyLabel: 
  ...
<b><font color="#3A3966">Return</font></b>

</font></pre></blockquote>
<b>概要</b><br><blockquote>


<b><font color="#3A3966">Gosub</font></b> stands for 'Go to sub routine'. A <a href="general_rules.html">label</a> must be specified after <b><font color="#3A3966">Gosub</font></b>, at that point 
the program execution continues immediately after the position defined by that label, and will do so until 
encountering a <b><font color="#3A3966">Return</font></b>. When a return is reached, the program execution is then transferred immediately 
below the <b><font color="#3A3966">Gosub</font></b>. 
<br>
<b><font color="#3A3966">Gosub</font></b> is useful when building fast structured code. 
<br>
<br>
Another technique which may be used in order to insert a sub routine into a standalone program component 
is to use <a href="procedures.html">procedures</a>. 
<b><font color="#3A3966">Gosub</font></b> may only be used within the main body of the source code, and may not be used within 
<a href="procedures.html">procedures</a>. 

 

</blockquote><p><b>示例</b></p><blockquote>


<pre><font face="Courier New, Courier, mono"size="2">  a = 1
  b = 2
  <b><font color="#3A3966">Gosub</font></b> ComplexOperation
  <b><font color="#3A3966">Debug</font></b> a
  <b><font color="#3A3966">End</font></b>
       
  ComplexOperation:
    a = b*2+a*3+(a+b)
    a = a+a*a
  <b><font color="#3A3966">Return</font></b> 
</font></pre>

</blockquote>
<br><b>语法</b><blockquote><pre><font face="Courier New, Courier, mono"size="2"><b><font color="#3A3966">FakeReturn</font></b> 
</font></pre></blockquote>
<b>概要</b><br><blockquote>





If the command <a href="others.html">Goto</a> is used within the body of a sub routine, <b><font color="#3A3966">FakeReturn</font></b> must be used. 
<b><font color="#3A3966">FakeReturn</font></b> simulates a return without actually executing a return, and if it is not used, the program will crash. 
Note: To exit a loop safely, <a href="break_continue.html">Break</a> should be used instead of Goto. 

 

</blockquote><p><b>示例</b></p><blockquote>


<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#3A3966">Gosub</font></b> SubRoutine1
     
  SubRoutine1:
    ...
    <b><font color="#3A3966">If</font></b> a = 10
      <b><font color="#3A3966">FakeReturn</font></b>
      <b><font color="#3A3966">Goto</font></b> Main_Loop
    <b><font color="#3A3966">EndIf</font></b>
  <b><font color="#3A3966">Return</font></b>
</font></pre>
</body></html>